<template>
  <!-- 登录 -->
  <div class="Longin">
    <img src="../assets/Login.jpg" alt="" />
    <van-button type="primary" :round="true" @click="Login1"
      >立即登录</van-button
    >
  </div>
</template>

<script>
import { Register, Login } from "@/request/api";
export default {
  name: "Login",
  data() {
    return {};
  },
  created() {
    //  请求注册
    //  请求登录
  },
  methods: {
    Login1() {
      //   Register({ phone: "13380094026", password: "123456" }).then((res) => {
      //     console.log(res.data);
      //   });
      Login({ username: "13380094026", password: "123456" }).then((res) => {
        // console.log(res);
        // 保存token
        localStorage.setItem("token", res.data);
        // 跳转到首页
        this.$router.push("/home");
      });
    },
  },
};
</script>
 
<style lang = "less" scoped>
.Longin {
  position: absolute;
  img {
    height: 100%;
    width: 100%;
  }
  /deep/.van-button {
    position: absolute;
    bottom: 1.5rem;
    left: 30%;
    width: 1.5rem;
    border-color: #000;
    border: 0.02rem solid #000;
    background-color: #4267fe;
  }
}
</style>